<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="css :: css">
</head>
<link href="/js/jquery.icheck/skins/square/blue.css" rel="stylesheet">
<link href="/css/bootstrap-toggle.min.css" rel="stylesheet">
<link href="/js/jquery.icheck/skins/square/blue.css" rel="stylesheet">
<link href="/css/chosen.css" rel="stylesheet">
<body style="opacity: 1">
<div style="padding-top: 0">
    <div class="container-fluid">
        <div class="cl-mcont">
            <div class="row">
                <div class="col-md-12" style="padding:0">
                    <div class="block-flat">
                        <form class="form-horizontal group-border-dashed" id="buyCode">
                            <input type="hidden" id="productTypes" name="productTypes">
                            <input type="hidden" id="statusArray" name="statusArray">
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" class="form-control" name="startTime"
                                           id="startTime" style="display: inline-block; width: 145px;">
                                    <input type="text" class="form-control" name="endTime"
                                           id="endTime" style="display: inline-block; width: 145px;">
                                </div>
                                <div class="input-group">
                                    <input type="text" class="form-control" id="sellerAlipayUserId"
                                           name="sellerAlipayUserId"
                                           placeholder="收款账号"/>
                                </div>
                                <div class="input-group">
                                    <input type="text" class="form-control" id="sellerRealName" name="sellerRealName"
                                           placeholder="收款姓名"/>
                                </div>
                                <div class="input-group">
                                    <select class="form-control " id="channel" name="channel">
                                        <option value="" selected>订单来源</option>
                                        <option value="0">闲鱼</option>
                                        <option value="1">茶蛋</option>
                                    </select>
                                </div>
                                <div class="input-group">
                                    <button class="btn btn-primary" type="button" id="search"><i
                                            class="fa fa-search"></i>查询
                                    </button>
                                </div>
                                <div class="input-group" id="export_Role">
                                    <button class="btn btn-default" type="button" id="export"><i
                                            class="fa fa-download"></i> 导出
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="block-flat">
                        <div class="content">
                            <div class="table-responsive">
                                <table class="table hover" id="dataTable">
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>

</div>
<div th:include="js :: js"></div>
<script type="text/javascript" th:attr="src=@{/js/jquery.form.js}"></script>
<script type="text/javascript" th:attr="src=@{/js/jquery.parser.js}"></script>
<script type="text/javascript" src="js/jquery.icheck/icheck.min.js"></script>
<script type="text/javascript" src="/js/chosen.jquery.js?deVersion=20181411895"></script>
<script>
    $(function () {
        buttonShiro("export_Role");
        var myDate = new Date();
        var month = myDate.getMonth() + 1;
        var day = myDate.getDate();
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        var _start = myDate.getFullYear() + '-' + month + '-' + day;
        var _end = myDate.getFullYear() + '-' + month + '-' + day;
        laydate.render({
            elem: '#startTime'
        });
        laydate.render({
            elem: '#endTime' //指定元素
        });
        $("#startTime").val(_start);
        $("#endTime").val(_end);
        $('#dataTable').bootstrapTable({
            url: '/finance/queryXianyuSupplyDailySheetPage',
            height: $(window).height() - 200,
            pageSize: 100,
            pagination: true,
            pageList: [30, 50, 100],
            clickToSelect: true,
            queryParams: queryParams,
            uniqueId: 'id',
            queryParamsType: '',
            sidePagination: 'server',
            responseHandler: function (res) {
                return {
                    "total": res.total,//总页数
                    "rows": res.resultList   //数据
                };
            },
            columns: [
                {
                    checkbox: true,
                    align: 'center'
                }, {
                    width: '3px',
                    align: 'center',
                    formatter: function (v, row, index) {
                        return index + 1
                    }
                },
                {field: 'startTime', title: '日期', width: 80, align: 'center'},
                {
                    field: 'userAccount',
                    title: '收款方式',
                    width: 90,
                    align: 'center',
                    formatter: function (v, row, index) {
                        return '支付宝'
                    }
                },
                {field: 'sellerRealName', title: '收款姓名', width: 70, align: 'center'},
                {
                    field: 'settleAmount',
                    title: '结算金额',
                    width: 50,
                    align: 'center'
                },
                {field: 'defference', title: '差额', width: 40, align: 'center'},
                {field: 'summaryFace', title: '汇总面值', width: 60, align: 'center'},
                {field: 'entryMoney', title: '汇总金额', width: 65, align: 'center'},
                {field: 'totalCommission', title: '佣金', width: 65, align: 'center'},
                {
                    field: 'channel', title: '订单来源', width: 40, align: 'center',
                    formatter: function (v, o) {
                        return o.channel == null ? '-' : (o.channel == 1 ? '茶蛋' : '闲鱼');
                    }
                },
                {field: 'mobileSuccessFace', title: '移动</br>成功面值', width: 60, align: 'center'},
                {field: 'mobileEntryMoney', title: '移动</br>入账金额', width: 60, align: 'center'},
                {field: 'unicomSuccessFace', title: '联通</br>成功面值', width: 60, align: 'center'},
                {field: 'unicomEntryMoney', title: '联通</br>入账金额', width: 60, align: 'center'},
                {field: 'telecomSuccessFace', title: '电信</br>成功面值', width: 60, align: 'center'},
                {field: 'telecomEntryMoney', title: '电信</br>入账金额', width: 60, align: 'center'},
                {field: 'fuelSuccessFace', title: '加油卡</br>成功面值', width: 60, align: 'center'},
                {field: 'fuelEntryMoney', title: '加油卡</br>入账金额', width: 60, align: 'center'},
                {field: 'equitySuccessFace', title: '权益</br>成功面值', width: 60, align: 'center'},
                {field: 'equityMoney', title: '权益</br>入账金额', width: 60, align: 'center'},
                {field: 'fixMoney', title: '补结金额</br>(三网)', width: 60, align: 'center'},
                {field: 'fixFuelMoney', title: '补结金额</br>(加油卡)', width: 60, align: 'center'},
                {field: 'fixEquityMoney', title: '补结金额</br>(权益)', width: 60, align: 'center'},
                {field: 'rebate', title: '服务费', width: 60, align: 'center'},
                {field: 'ejfMoney', title: '易缴费汇总金额', width: 60, align: 'center'},
                {field: 'easyServerMoney', title: '易服务汇总金额', width: 60, align: 'center'}
            ]
        });
        $("#search").click(function () {
            var timeAdd = new Date($("#startTime").val());
            var timeEnd = new Date($("#endTime").val());
            if (timeAdd > timeEnd) {
                layer.msg("开始时间不能大于结束时间");
                return false;
            }
            var require = (timeEnd - timeAdd) / (1 * 24 * 60 * 60 * 1000);
            if (require > 7) {
                layer.msg("时间间隔不能超过7天");
                return;
            }
            $("#dataTable").bootstrapTable("refresh");
        });

        //下载
        $("#export").click(function () {
            var timeAdd = new Date($("#startTime").val());
            var timeEnd = new Date($("#endTime").val());
            var require = (timeEnd - timeAdd) / (1 * 24 * 60 * 60 * 1000);
            if (require > 6) {
                layer.msg("只能下载七天的数据");
                return;
            }
            window.location.href = "/finance/dailyXianyuReportdownLoad?" + $("#buyCode").serialize()
        })


        function queryParams(params) {
            return {
                page: params.pageNumber,
                size: params.pageSize,
                startTime: $("#startTime").val(),
                endTime: $("#endTime").val(),
                sellerAlipayUserId: $.trim($("#sellerAlipayUserId").val()),
                sellerRealName: $.trim($("#sellerRealName").val()),
                channel: $("#channel").val()
            };
        }
    })

</script>
</body>
</html>
